/*
 * Copyright 2004-2008 the Seasar Foundation and the Others.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package com.yakaten.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


import net.arnx.jsonic.JSON;

import org.seasar.framework.beans.util.BeanMap;
import org.seasar.struts.annotation.Execute;

public class CategoryMngAction extends BaseAction {
	
    @Execute(validator = false)
	public String index() {
        return "../categoryMng.jsp";
	}
    
    @Execute(validator = false)
	public String getAllCategory() throws IOException {

    	List<BeanMap> result = new ArrayList<BeanMap>();
    	
    	BeanMap map1= new BeanMap();
    	map1.put("categoryCode", "1");
    	map1.put("categoryName", "ノードパソコン");
    	map1.put("jancdCount", "111,111");
    	map1.put("itemCount", "111,111,111");
    	result.add(map1);
    	
    	BeanMap map2= new BeanMap();
    	map2.put("categoryCode", "2");
    	map2.put("categoryName", "デスクトップパソコン");
    	map2.put("jancdCount", "222,222");
    	map2.put("itemCount", "222,222,222");
    	result.add(map2);
    	
    	BeanMap map3= new BeanMap();
    	map3.put("categoryCode", "3");
    	map3.put("categoryName", "プリンタ");
    	map3.put("jancdCount", "333333");
    	map3.put("itemCount", "333333333");
    	result.add(map3);
    	
    	BeanMap map4= new BeanMap();
    	map4.put("categoryCode", "4");
    	map4.put("categoryName", "パソコン周辺機器");
    	map4.put("jancdCount", "444444");
    	map4.put("itemCount", "444444444");
    	result.add(map4);
 
    	BeanMap map5= new BeanMap();
    	map5.put("categoryCode", "5");
    	map5.put("categoryName", "カメラ");
    	map5.put("jancdCount", "555555");
    	map5.put("itemCount", "555555555");
    	result.add(map5);
   
    	BeanMap map6= new BeanMap();
    	map6.put("categoryCode", "6");
    	map6.put("categoryName", "AV機器");
    	map6.put("jancdCount", "666666");
    	map6.put("itemCount", "666666666");
    	result.add(map6);
   
    	BeanMap map7= new BeanMap();
    	map7.put("categoryCode", "7");
    	map7.put("categoryName", "生活家電");
    	map7.put("jancdCount", "777777");
    	map7.put("itemCount", "777777777");
    	result.add(map7);
    	
    	BeanMap map8= new BeanMap();
    	map8.put("categoryCode", "6");
    	map8.put("categoryName", "サービス");
    	map8.put("jancdCount", "888888");
    	map8.put("itemCount", "888888888");
    	result.add(map8);
    	
    	response.getWriter().write("{\"totalCount\":\"" + 2 + "\",\"results\":"
                + JSON.encode(result) + "}");
    	
    	return null;
	}
}
